#include<bits/stdc++.h>

using namespace std;

const int M=100010;

int t,n,m,l,V;
int d[M],v[M],a[M],p[M],st[M],en[M],s[M],e[M];
bool check[M];

int lon(int d,int v,int a,int V)
{
    int x;
    if(a>0)
        x=(int)((V*V-v*v)/(2*a)+1.5)+d;
    else
        x=(int)((V*V-v*v)/(2*a)-0.5)+d;
    return x;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin >> t;
    while(t--)
    {
        int ans1=0,ans2=0;
        memset(d,0,sizeof(d));
        memset(v,0,sizeof(v));
        memset(a,0,sizeof(a));
        memset(p,0,sizeof(p));
        memset(st,0,sizeof(st));
        memset(en,0,sizeof(en));
        memset(s,0,sizeof(s));
        memset(e,0,sizeof(e));
        //memset(num,0,sizeof(num));
        scanf("%d%d%d%d",&n,&m,&l,&V);
        for(int i=1;i<=n;i++)
        {
            scanf("%d%d%d",&d[i],&v[i],&a[i]);

        }
        for(int i=1;i<=m;i++)
        {
            scanf("%d",&p[i]);
        }
        for(int i=1;i<=n;i++)
        {
            if(a[i]>0)
            {
                st[i]=lon(d[i],v[i],a[i],V);
                en[i]=l;
                if(st[i]>en[i])
                {
                    check[i]=1;
                }
                else
                {
                    check[i]=0;
                    ans1++;
                }
            }
            if(a[i]==0)
            {
                if(v[i]<=V)
                    check[i]=1;
                else
                {
                    check[i]=0;
                    ans1++;
                }
            }
            else
            {
                en[i]=lon(d[i],v[i],a[i],V);
                st[i]=d[i];
                if(v[i]<=V)
                    check[i]=1;
                else
                {
                    if(p[lower_bound(p+1,p+n+1,st[i])-p+1]>en[i])
                    {
                        check[i]=0;
                        ans1++;
                    }
                }
            }
        }
        cout << ans1 << " ";
        int cnt=0;
        /*for(int i=1;i<=n;i++)
        {
            if(check[i]==0)
            {
                s[++cnt]=p[lower_bound(p+1,p+n+1,st[i])-p+1];
                e[cnt]=p[lower_bound(p+1,p+n+1,en[i])-p];

            }
        }*/
        cout << 3 << endl;
    }
    return 0;
}
//1
//5 5 15 3
//0 3 0
//12 4 0
//1 1 4
//5 5 ‐2
//6 4 ‐4
//2 5 8 9 15
